<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<script src="${pageContext.request.contextPath}/layer-v2.1/layer/layer.js"></script>
<script type="text/javascript">
	function deviceDelete(id){
		if(confirm("确定要删除这条记录吗?")){
			$.post("${pageContext.request.contextPath}/device/delete.do",{id:id},
				function(result){
					var result=eval('('+result+')');
					if(result.errorInfo){
						alert(result.errorInfo);
					}else{
						alert("删除成功");
						window.location.href="${pageContext.request.contextPath}/device/list.do";
					}
				}
			);
		}
	}
	
	function show(id) {
		//iframe层
		layer.open({
		    type: 2,
		    title: '规格型号详情',
		    shadeClose: true,
		    shade: 0.3,
		    area: ['400px', '460px'],
		    content: '${pageContext.request.contextPath}/hardware/preSave.do?id='+id //iframe的url
		}); 
	}
	function showMLog(id) {
		//iframe层
		layer.open({
		    type: 2,
		    title: '状态详情',
		    shadeClose: true,
		    shade: 0.3,
		    area: ['800px', '400px'],
		    content: '${pageContext.request.contextPath}/mlog/list.do?id='+id //iframe的url
		}); 
	}
</script>
<form action="${pageContext.request.contextPath}/device/list.do" method="post">
<table class="row">
  <tr>
    <td class="col-md-3">
		<select class="form-control" name="keyname" >
										
		  <option value="1" <c:if test="${keyword.keyname == '1'}">selected</c:if>>资产编码</option>
		  <option value="2" <c:if test="${keyword.keyname == '2'}">selected</c:if>>资产名称</option>
		  <option value="3" <c:if test="${keyword.keyname == '3'}">selected</c:if>>规格型号</option>
		  <option value="4" <c:if test="${keyword.keyname == '4'}">selected</c:if>>计量单位</option>
		  <option value="5" <c:if test="${keyword.keyname == '5'}">selected</c:if>>资产数量</option>
		  <option value="6" <c:if test="${keyword.keyname == '6'}">selected</c:if>>入库时间</option>
		  <option value="7" <c:if test="${keyword.keyname == '7'}">selected</c:if>>使用部门</option>
		  <option value="8" <c:if test="${keyword.keyname == '8'}">selected</c:if>>安装地点</option>
		  <option value="9" <c:if test="${keyword.keyname == '9'}">selected</c:if>> 保管人 </option>
		  
		</select>
	</td>
	
    <td>
		<div class="col-md-5">
		
	    <div class="input-group" style="width: 300px">
		      <input type="text" class="form-control" name="keyword"  value="${keyword.keyword }" placeholder="请输入关键字...">
		      <span class="input-group-btn">
		        <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span>&nbsp;查询</button>
		      </span>
	    </div>
	    
	    </div>
	</td>
  </tr>
</table>
</form>
	<div class="col-md-12">
  	<button type="button" class="btn btn-primary" style="float: right;" onclick="javascript:window.location.href='${pageContext.request.contextPath}/device/preSave.do'">添加</button>
	</div>
<div>
	<table class="table table-hover  table-bordered table-striped" style="margin-bottom: 0px;">
	  <tr>
	  	<th>序号</th>
	  	<th>资产编码</th>
	  	<th>资产名称</th>
	  	<th>规格型号</th>
	  	<th>状态</th>
	  	<th>计量单位</th>
	  	<th>资产数量</th>
	  	<th>入库时间</th>
	  	<th>使用部门</th>
	  	<th>安装地点</th>
	  	<th>保管人</th>
	  	<th>操作</th>
	  </tr>
	  <c:forEach var="item" items="${deviceList }" varStatus="status">
	  	<tr>
	  		<td>${status.index+1 }</td>
	  		<td>${item.assetId}</td>
	  		<td>${item.assetName}</td>
	  		<td>${item.type}&nbsp;<button type="button" class="btn btn-info btn-xs" onclick="show(${item.id});">详情</button></td>
	  		<td>${item.stat}<c:if test="${item.stat.length()<2}"> 未知</c:if>&nbsp;<button type="button" class="btn btn-info btn-xs" onclick="showMLog(${item.id});">详情</button></td>
	  		<td>${item.unitName}</td>
	  		<td>${item.assetNumber}</td>
	  		<td>${item.inTime}</td>
	  		<td>${item.useDepartment}</td>
	  		<td>${item.installationSite}</td>
	  		<td>${item.keeper}</td>
	  		<td>
	  			<button type="button" class="btn btn-info btn-xs" onclick="javascript:window.location.href='${pageContext.request.contextPath}/device/preSave.do?id=${item.id }'">修改</button>
	  			<button type="button" class="btn btn-danger btn-xs" onclick="deviceDelete(${item.id })">删除</button>
	  		</td>
	  	</tr>
	  </c:forEach>
	</table>
	<nav >
		<ul class="pagination">${pageCode}</ul>
	</nav>
</div>



